package com.jisuan.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jisuan.contract.common.utils.PageResult;
import com.jisuan.contract.common.utils.Query;
import com.jisuan.contract.dao.BorrowingUserDao;
import com.jisuan.contract.entity.BorrowingUserEntity;
import com.jisuan.contract.service.BorrowingUserService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("borrowingUserService")
public class BorrowingUserServiceImpl extends ServiceImpl<BorrowingUserDao, BorrowingUserEntity> implements BorrowingUserService {

    @Override
    public PageResult queryPage(Map<String, Object> params, BorrowingUserEntity borrowingUser)
    {
        LambdaQueryWrapper<BorrowingUserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(
                borrowingUser.getBorrowingName() != null,
                BorrowingUserEntity::getBorrowingName, borrowingUser.getBorrowingName()
        );
        IPage<BorrowingUserEntity> page = this.page(
                new Query<BorrowingUserEntity>().getPage(params),
                queryWrapper
        );
        return new PageResult(page);
    }

}